<template>
    <div>
        <button @click="increment">+1</button>
        <button @click="decrement">-1</button>
        <button @click="incrementTen">+10</button>
    </div>
</template>

<script>
    export default {
        // emits: ["addOne","subOne"],
        emits:{ //只会报警告,但是也会传递过去 可有可无
            addOne: null,   //不需要验证
            subOne: null,   //不需要验证
            addTen: function(payload){  //对传递参数进行验证
                if(payload === 10){
                    return true
                }
                return false
            }
        },  
        methods: {
            increment(){
                this.$emit("addOne")
            },
            decrement(){
                this.$emit("subOne")
            },
            incrementTen(){ //传参数给父组件
                this.$emit("addTen",11)
            }
        }
    }
</script>

<style lang="scss" scoped>

</style>